<template>
	<view class="u-p-20">
		<view class="" v-for="(item,index) in mess" :key="index" @click="$u.route(`/subcontract/mymassage/systemMessages/detail?announce_id=${item.id}`)">
			<view class="u-text-center u-p-t-20 u-p-b-20 u-font-20 cl_848484FF">{{item.create_time}}</view>
			<view class="bg_FFFFFF u-b-r-20 u-p-l-30 u-p-r-30 u-p-b-30 u-p-t-20">
				<view v-if="item.is_read==0" class="u-flex u-row-right">
					<view class="u-w-15 u-h-15 u-m-b-20 u-b-r-10 bg_FC3533FF">
						
					</view>
				</view>
				<view class="u-weight" style="padding-bottom: 20rpx;">{{item.name}}</view>
				<view class="">
					<!-- #ifdef MP-WEIXIN-->
					<view class="u-font-20 u-m-t-10 u-w-450 text-cut-2" style="max-height: 400rpx;">
						<u-parse :html="item.detail"></u-parse>
					</view>
					<!-- #endif -->
					<!-- #ifndef MP-WEIXIN-->
					<view class="u-font-20 u-m-t-10 u-w-450 text-cut-2" style="max-height: 400rpx;">
						<u-parse :html="item.detail"></u-parse>
					</view>
					<!-- #endif -->
					<view class="u-m-t-10 u-font-20 cl_FF2D23FF">
						<view class="u-text-right u-b-4">
							<text>立即查看</text>
							<u-icon name="arrow-right" color="#FF2D23FF"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 加载更多 -->
		<u-loadmore :status="status" icon-type="circle" margin-top="20" margin-bottom="20" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mess:[],
				messParams:{
					type:0,
					page:1,
					page_size:20
				},
				status: 'loadmore',
			}
		},
		onLoad(o) {
			this.messParams.type=o.type
			uni.setNavigationBarTitle({
				title:o.type==0?'系统消息':o.type==1?'订单消息':'通知消息'
			})
			this.clear()
			this.announce_list()
		},
		// 下拉到底事件
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.announce_list();
		},
		methods: {
			clear() {
				this.mess = [];
				this.messParams.page = 1;
			},
			async announce_list() {
				await this.$api.announce_list(this.messParams, res => {
					if (res.data.code == 1) {
						if (res.data.data.data.length < 20) {
							this.status = 'nomore';
						} else {
							this.messParams.page = this.messParams.page + 1;
							this.status = 'loadmore';
						}
						this.mess = this.mess.concat(res.data.data.data);
						uni.stopPullDownRefresh();
					}
				})
			},
		}
	}
</script>

<style scoped>
	page {
		background: #F5F5F5FF !important;
	}
</style>
